package com.bluesky.drcp.business.service;

import java.util.List;

import com.bluesky.drcp.business.Module;
import com.bluesky.drcp.persistence.dao.ModuleDao;

public class ModuleService {
	private ModuleDao moduleDao;

	private FunctionModuleService functionModuleService;

	public Module get(String id) {
		return moduleDao.get(id);
	}

	public FunctionModuleService getFunctionModuleService() {
		return functionModuleService;
	}

	public void setFunctionModuleService(
			FunctionModuleService functionModuleService) {
		this.functionModuleService = functionModuleService;
	}

	public Module getByFunctionId(String functionId) {
		try {
			String moduleId = functionModuleService
					.getModuleIdByFunctionId(functionId);

			return moduleDao.get(moduleId);
		} catch (Exception e) {
		}
		return null;
	}

	public ModuleDao getModuleDao() {
		return moduleDao;
	}

	public void setModuleDao(ModuleDao moduleDao) {
		this.moduleDao = moduleDao;
	}

	public List getAll() {
		return moduleDao.getAll();
	}
	
	public void save(Module module) {
		moduleDao.save(module);
	}

	public void update(Module module) {
		moduleDao.update(module);
	}

	public void delete(String moduleId) {
		moduleDao.delete(moduleId);
	}
}
